<?php
//这里是公共前置
use admin\Fun;

define('cookiehash',substr(md5(Config(".siteHash")),0,6));
//判断是否是登录页，不是登录页面就判断登录信息
if(M_C["class"]!="login"){
    Fun::ckLogin();
}
$inputkindarray=array(
    array('id'=>'1',	'name'=>'文本框',				'kind'=>'varchar',		'setting'=>0),
    array('id'=>'2',	'name'=>'多行文本',				'kind'=>'text',			'setting'=>0),
    array('id'=>'3',	'name'=>'编辑框(简单)',			'kind'=>'text',			'setting'=>0),
    array('id'=>'4',	'name'=>'编辑框(全功能)',		'kind'=>'text',			'setting'=>0),
    array('id'=>'24',	'name'=>'编辑框(MarkDown)',		'kind'=>'text',			'setting'=>0),
    array('id'=>'5',	'name'=>'文件/图片上传',		'kind'=>'varchar',		'setting'=>0),
    array('id'=>'6',	'name'=>'多图上传',				'kind'=>'text',			'setting'=>0),
    array('id'=>'7',	'name'=>'数字/排序',			'kind'=>'int',			'setting'=>0),
    array('id'=>'9',	'name'=>'时间',					'kind'=>'int',			'setting'=>0),
    array('id'=>'26',	'name'=>'勾选框(是否)',			'kind'=>'int',			'setting'=>0),
    array('id'=>'12',	'name'=>'单选框',				'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'10',	'name'=>'多选框',				'kind'=>'varchar',		'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'15',	'name'=>'多选框(搜索)',			'kind'=>'varchar',		'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'11',	'name'=>'列表框',				'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'8',	'name'=>'列表框(树形)',			'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源,来源栏目下必须有fid字段'),
    array('id'=>'14',	'name'=>'列表框(搜索)',			'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'17',	'name'=>'列表框(联动)',			'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源,来源栏目下必须有fid字段'),
    array('id'=>'21',	'name'=>'文章单选',				'kind'=>'int',			'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'22',	'name'=>'文章多选',				'kind'=>'varchar',		'setting'=>1,	'strfrom'=>1,	'tips'=>'字段数据来源'),
    array('id'=>'27',	'name'=>'文章多选(全站)',		'kind'=>'varchar',		'setting'=>0),
    array('id'=>'28',	'name'=>'栏目单选',				'kind'=>'int',			'setting'=>0),
    array('id'=>'29',	'name'=>'栏目多选',				'kind'=>'varchar',		'setting'=>0),
    array('id'=>'16',	'name'=>'颜色选择器',			'kind'=>'varchar',		'setting'=>0),
    array('id'=>'18',	'name'=>'TAGS(竖)',				'kind'=>'text',			'setting'=>0),
    array('id'=>'19',	'name'=>'TAGS(横)',				'kind'=>'text',			'setting'=>0),
    array('id'=>'23',	'name'=>'地图坐标',				'kind'=>'varchar',		'setting'=>0),
    array('id'=>'30',	'name'=>'自定义',				'kind'=>'varchar',		'setting'=>1,	'strfrom'=>2,	'tips'=>'自定义函数名 帮助:http://uuu.la/help/diyinput.html'),
);
$notallowfield=array('id','posttime','cid','adminuid','rowstyle','stepstyle','rowurl','link','refererurl','articletable','like','add','all','alter','as','and','asc'
,'before','between','bigint','binary','blob','both','by','call','cascade','case','change','char','check','column','create'
,'cross','cursor','databases','database','dec','delete','default','desc','div','double','drop','each','else','elseif','exists'
,'exit','explain','false','float','for','force','from','foreign','goto','group','if','in','index','inner','inout'
,'insert','int','integer','into','is','join','key','kill','keys','left','limit','lines','load','lock','loop','long','mod','not'
,'null','on','option','or','order','out','outer','outfile','primary','range','read','reads','real','set','show','sql'
,'ssl','starting','then','table','to','undo','true','union','unlock','update','using','values','varchar'
,'when','where','while','with','write');

function power($kind,$id='',$powers=0,$action='') {
    if($powers==0) {
        global $power;
    }else {
        $power=$powers;
    }
    if($kind=='alevel') {
        if(isset($power['alevel'])) {Return $power['alevel'];}else {Return 0;}
    }
    if($kind=='b') {
        if(isset($power[$kind][$id]) && $power[$kind][$id]==1) {
            Return true;
        }else {
            Return false;
        }
    }
    if(isset($power['alevel']) && $power['alevel']>1) {
        Return true;
    }
    if(!isset($power[$kind])) {
        Return false;
    }elseif($kind=='s' && !isset($power[$kind][$id][0]) && !empty($action)){
        Return false;
    }else {
        if(isset($power[$kind][$id]) && $action=='') {
            Return true;
        }else {
            if(isset($power[$kind][$id][$action]) && $power[$kind][$id][$action]==1) {
                Return true;
            }else {
                Return false;
            }
        }
    }
    Return false;
}

//展示界面后台
function layout($name="",$data=null)
{
    if($data===null || !is_array($data)){
        $data=[];
    }
    if(is_array($name)){
        $data=array_merge($data,$name);
        $name="";
    }
    if(is_array($data)){
        $data["layout"]=$name;
    }
    show("admin/layout",$data);
}
function layout2($name="",$data=null)
{
    if($data===null || !is_array($data)){
        $data=[];
    }
    if(is_array($name)){
        $data=array_merge($data,$name);
        $name="";
    }
    if(is_array($data)){
        $data["layout"]=$name;
    }
    show("admin/layout2",$data);
}

//获取左侧列表
function getLeftList(){


}